package sunsun.xiaoli.jiarebang.adapter;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.itboye.pondteam.bean.PondCleanRecords;
import com.itboye.pondteam.volley.TimesUtils;
import sunsun.xiaoli.jiarebang.R;

import java.util.ArrayList;


public class PondCleanLogsAdapter extends BaseAdapter {
    ArrayList<PondCleanRecords> cleanLogList;
    Context context;

    public PondCleanLogsAdapter(ArrayList<PondCleanRecords> cleanLogList, Context context) {
        this.cleanLogList = cleanLogList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return cleanLogList.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.item_pond_clean_logs, null);
            viewHolder.item_tv_pond_clean_logs = convertView.findViewById(R.id.item_tv_pond_clean_logs);
            viewHolder.item_tv_pond_clean_logs_duration = convertView.findViewById(R.id.item_tv_pond_clean_logs_duration);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.item_tv_pond_clean_logs.setText(Html.fromHtml(context.getString(R.string.clean_time) + TimesUtils.getStringTime(cleanLogList.get(position).getCreate_time(), "yyyy-MM-dd HH:mm:ss")));
        viewHolder.item_tv_pond_clean_logs_duration.setText(cleanLogList.get(position).getCl_dur() + "s");
        return convertView;
    }

    class ViewHolder {
        TextView item_tv_pond_clean_logs;
        TextView item_tv_pond_clean_logs_duration;
    }


}
